package myThread;

public class demo12 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("thread 线程结束");
        });
        System.out.println("hello main");


        t.start();
        System.out.println("main 线程");
        t.join(3000);//main线程最多等3秒
        System.out.println("main 线程结束");
    }
}
